licenses(["notice"])

package(default_visibility = ["//visibility:public"])

java_library(
    name = "promote_key_command",
    srcs = ["PromoteKeyCommand.java"],
    deps = [
        ":command",
        ":key_id_options",
        ":tinkey_util",
    ],
)

java_library(
    name = "enable_key_command",
    srcs = ["EnableKeyCommand.java"],
    deps = [
        ":command",
        ":key_id_options",
        ":tinkey_util",
    ],
)

java_library(
    name = "convert_keyset_options",
    srcs = ["ConvertKeysetOptions.java"],
    deps = [
        ":out_options",
        ":tinkey_util",
        "@maven//:args4j_args4j",
        "@tink_java//src/main/java/com/google/crypto/tink/subtle:validators",
    ],
)

java_library(
    name = "tinkey",
    srcs = ["Tinkey.java"],
    deps = [
        ":kms_clients_factory",
        ":tinkey_commands",
        "@maven//:args4j_args4j",
        "@tink_java//src/main/java/com/google/crypto/tink/daead:deterministic_aead_config",
        "@tink_java//src/main/java/com/google/crypto/tink/hybrid:hybrid_config",
        "@tink_java//src/main/java/com/google/crypto/tink/integration/awskms:aws_kms_client",
        "@tink_java//src/main/java/com/google/crypto/tink/integration/gcpkms:gcp_kms_client",
        "@tink_java//src/main/java/com/google/crypto/tink/jwt:jwt_mac_config",
        "@tink_java//src/main/java/com/google/crypto/tink/jwt:jwt_signature_config",
        "@tink_java//src/main/java/com/google/crypto/tink/keyderivation:key_derivation_config",
        "@tink_java//src/main/java/com/google/crypto/tink/prf:prf_config",
        "@tink_java//src/main/java/com/google/crypto/tink/signature:signature_config",
        "@tink_java//src/main/java/com/google/crypto/tink/streamingaead:streaming_aead_config",
    ],
)

java_library(
    name = "tinkey_commands",
    srcs = ["TinkeyCommands.java"],
    deps = [
        ":add_key_command",
        ":command",
        ":convert_keyset_command",
        ":create_keyset_command",
        ":create_public_keyset_command",
        ":delete_key_command",
        ":destroy_key_command",
        ":disable_key_command",
        ":enable_key_command",
        ":help_command",
        ":list_key_templates_command",
        ":list_keyset_command",
        ":promote_key_command",
        ":rotate_keyset_command",
        "@maven//:args4j_args4j",
    ],
)

java_library(
    name = "key_template_handler",
    srcs = ["KeyTemplateHandler.java"],
    deps = [
        ":tinkey_key_templates",
        "@maven//:args4j_args4j",
        "@tink_java//src/main/java/com/google/crypto/tink:key_template",
        "@tink_java//src/main/java/com/google/crypto/tink:key_templates",
    ],
)

java_library(
    name = "out_options",
    srcs = ["OutOptions.java"],
    deps = [
        ":in_options",
        ":output_stream_handler",
        ":tinkey_util",
        "@maven//:args4j_args4j",
    ],
)

java_library(
    name = "rotate_keyset_command",
    srcs = ["RotateKeysetCommand.java"],
    deps = [
        ":add_rotate_options",
        ":command",
        ":tinkey_util",
        "@tink_java//src/main/java/com/google/crypto/tink:key_template",
    ],
)

java_library(
    name = "tinkey_util",
    srcs = ["TinkeyUtil.java"],
    deps = [
        ":kms_clients_factory",
        "@tink_java//src/main/java/com/google/crypto/tink:aead",
        "@tink_java//src/main/java/com/google/crypto/tink:insecure_secret_key_access",
        "@tink_java//src/main/java/com/google/crypto/tink:key_template",
        "@tink_java//src/main/java/com/google/crypto/tink:registry_cluster",
        "@tink_java//src/main/java/com/google/crypto/tink:tink_json_proto_keyset_format",
        "@tink_java//src/main/java/com/google/crypto/tink:tink_proto_keyset_format",
        "@tink_java//src/main/java/com/google/crypto/tink:parameters",
    ],
)

java_library(
    name = "key_id_handler",
    srcs = ["KeyIdHandler.java"],
    deps = [
        "@maven//:args4j_args4j",
    ],
)

java_library(
    name = "key_id_options",
    srcs = ["KeyIdOptions.java"],
    deps = [
        ":out_options",
        ":key_id_handler",
        "@maven//:args4j_args4j",
    ],
)

java_library(
    name = "convert_keyset_command",
    srcs = ["ConvertKeysetCommand.java"],
    deps = [
        ":command",
        ":convert_keyset_options",
        ":tinkey_util",
        "@tink_java//src/main/java/com/google/crypto/tink:registry_cluster",
    ],
)

java_library(
    name = "in_options",
    srcs = ["InOptions.java"],
    deps = [
        ":input_stream_handler",
        ":tinkey_util",
        "@maven//:args4j_args4j",
        "@tink_java//src/main/java/com/google/crypto/tink/subtle:validators",
    ],
)

java_library(
    name = "create_public_keyset_command",
    srcs = ["CreatePublicKeysetCommand.java"],
    deps = [
        ":command",
        ":out_options",
        ":tinkey_util",
        "@tink_java//src/main/java/com/google/crypto/tink:keyset_writer",
        "@tink_java//src/main/java/com/google/crypto/tink:registry_cluster",
    ],
)

java_library(
    name = "add_key_command",
    srcs = ["AddKeyCommand.java"],
    deps = [
        ":add_rotate_options",
        ":command",
        ":tinkey_util",
        "@tink_java//src/main/java/com/google/crypto/tink:key_template",
    ],
)

java_library(
    name = "list_keyset_command",
    srcs = ["ListKeysetCommand.java"],
    deps = [
        ":command",
        ":in_options",
        ":tinkey_util",
        "@tink_java//proto:tink_java_proto",
        "@tink_java//src/main/java/com/google/crypto/tink:registry_cluster",
    ],
)

java_library(
    name = "delete_key_command",
    srcs = ["DeleteKeyCommand.java"],
    deps = [
        ":command",
        ":key_id_options",
        ":tinkey_util",
    ],
)

java_library(
    name = "destroy_key_command",
    srcs = ["DestroyKeyCommand.java"],
    deps = [
        ":command",
        ":key_id_options",
        ":tinkey_util",
    ],
)

java_library(
    name = "input_stream_handler",
    srcs = ["InputStreamHandler.java"],
    deps = [
        "@maven//:args4j_args4j",
        "@tink_java//src/main/java/com/google/crypto/tink/subtle:validators",
    ],
)

java_library(
    name = "command",
    srcs = ["Command.java"],
)

java_library(
    name = "create_keyset_command",
    srcs = ["CreateKeysetCommand.java"],
    deps = [
        ":command",
        ":create_keyset_options",
        ":tinkey_util",
        "@tink_java//src/main/java/com/google/crypto/tink:key_template",
    ],
)

java_library(
    name = "disable_key_command",
    srcs = ["DisableKeyCommand.java"],
    deps = [
        ":command",
        ":key_id_options",
        ":tinkey_util",
    ],
)

java_library(
    name = "add_rotate_options",
    srcs = ["AddRotateOptions.java"],
    deps = [
        ":key_template_handler",
        ":out_options",
        "@maven//:args4j_args4j",
        "@tink_java//src/main/java/com/google/crypto/tink:key_template",
    ],
)

java_library(
    name = "output_stream_handler",
    srcs = ["OutputStreamHandler.java"],
    deps = [
        "@maven//:args4j_args4j",
        "@tink_java//src/main/java/com/google/crypto/tink/subtle:validators",
    ],
)

java_library(
    name = "list_key_templates_command",
    srcs = ["ListKeyTemplatesCommand.java"],
    deps = [
        ":command",
        ":tinkey_key_templates",
        "@tink_java//src/main/java/com/google/crypto/tink:registry",
    ],
)

java_library(
    name = "create_keyset_options",
    srcs = ["CreateKeysetOptions.java"],
    deps = [
        ":key_template_handler",
        ":out_options",
        "@maven//:args4j_args4j",
        "@tink_java//src/main/java/com/google/crypto/tink:key_template",
    ],
)

java_library(
    name = "tinkey_key_templates",
    srcs = ["TinkeyKeyTemplates.java"],
    deps = [
        "@tink_java//src/main/java/com/google/crypto/tink:key_template",
        "@tink_java//src/main/java/com/google/crypto/tink:key_templates",
        "@tink_java//src/main/java/com/google/crypto/tink/keyderivation:prf_based_key_derivation_parameters",
        "@tink_java//src/main/java/com/google/crypto/tink/prf:prf_parameters",
    ],
)

java_library(
    name = "help_command",
    srcs = ["HelpCommand.java"],
    deps = [":command"],
)

java_library(
    name = "tinkey_test_kms_client",
    testonly = 1,
    srcs = ["TinkeyTestKmsClient.java"],
    plugins = [":auto_service_plugin"],
    deps = [
        "@maven//:com_google_auto_service_auto_service_annotations",
        "@tink_java//src/main/java/com/google/crypto/tink:aead",
        "@tink_java//src/main/java/com/google/crypto/tink:insecure_secret_key_access",
        "@tink_java//src/main/java/com/google/crypto/tink:kms_client",
        "@tink_java//src/main/java/com/google/crypto/tink:registry_cluster",
        "@tink_java//src/main/java/com/google/crypto/tink:tink_json_proto_keyset_format",
    ],
)

java_plugin(
    name = "auto_service_plugin",
    processor_class = "com.google.auto.service.processor.AutoServiceProcessor",
    deps = [
        "@maven//:com_google_auto_auto_common",
        "@maven//:com_google_auto_service_auto_service",
    ],
)

java_library(
    name = "kms_clients_factory",
    srcs = ["KmsClientsFactory.java"],
    deps = [
        "@tink_java//src/main/java/com/google/crypto/tink:kms_client",
    ],
)
